package com.exam.controller;

import com.exam.entity.PracticeQuestion;
import com.exam.service.PracticeQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

//错题库生成训练题
@RestController
@RequestMapping("/api/practice-questions")
public class PracticeQuestionController {

    @Autowired
    private PracticeQuestionService practiceQuestionService;

    @GetMapping("/generate")
    public Page<PracticeQuestion> generatePracticeQuestions(
            @RequestParam(defaultValue = "0") int page,
            @RequestParam(defaultValue = "10") int size
    ) {
        Pageable pageable = PageRequest.of(page, size);
        return practiceQuestionService.generatePracticeQuestionsFromWrongQuestions(pageable);
    }
}